<template>
  <h1>日期时间选择器</h1>
  <el-date-picker
    type="date"
    v-model="rq"
    @change="console.log(rq);"
    format="YYYY-MM-DD"
    value-format="YYYY-MM-DD"
    placeholder="选择出发日期"
  ></el-date-picker>
  <el-time-picker
    type="datetime"
    v-model="sj"
    @change="console.log(sj);"
    format="YYYY-MM-DD HH:mm:ss"
    value-format="YYYY-MM-DD HH:mm:ss"
    placeholder="请选择下单时间"
  ></el-time-picker>
  <br>
  <el-date-picker
    type="datetimerange"
    v-model="times"
    @change="f"
    format="YYYY-MM-DD HH:mm:ss"
    value-format="YYYY-MM-DD HH:mm:ss"
    start-placeholder="开始日期"
    end-placeholder="结束日期"
    range-separator="至"
  ></el-date-picker>

</template>

<script setup>
import {ref} from "vue";

//定义变量用来保存用户选择的日期
const rq = ref('');
//定义变量用来保存用户选择的时间
const sj = ref('');
//定义数组用来保存起止时间
const times=ref([]);
const f=()=>{
  console.log(times.value);
  console.log(times.value[0]);
  console.log(times.value[1]);
}
</script>


<style scoped>

</style>